import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { ResouceConst } from "../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../resource/ImagesConst";
import { ObjCreate } from "../common/ObjCreate";
import { BaseItem } from "../common/BaseItem";
import { GTextFormat } from "../../../common/GTextFormat";
import { WardrobeState } from "../wardrobe/WardrobeState";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { WardrobeItemInfo } from "../wardrobe/WardrobeItemInfo";
import { ItemData } from "../../resource/info/ItemData";
import { ColorConfig } from "../../resource/ColorConfig";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { Cache } from "../../cache/Cache";
import { WardrobeType } from "../wardrobe/WardrobeType";
import { EDressPos } from "../../../../Message/Public/EDressPos";
import { Language } from "../../../../extend/language/Language";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { KeyBoardManager } from "../../../../com/gengine/keyBoard/KeyBoardManager";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
type int = number;
//class FashionBoxItemRender
    
    export  class FashionBoxItemRender extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            addEventListener(flash.events.MouseEvent.CLICK, this.onWardrobeItemClickHandler);
            return;
        }

        /* internal  */init(): void
        {
            this._bg = ResouceConst.getScaleBitmap(ImagesConst.WardrobeBoeder);
            this._bg.setSize(88, 107);
            this._bg.x = 2;
            this._bg.y = 2;
            addChild(this._bg);
            ObjCreate.createBg(12, 12, 66, 66, this, ImagesConst.PackItemBg);
            ObjCreate.createBg(3, 80, 88, 20, this, ImagesConst.FightingStrgBg);
            this._baseItem = new BaseItem();
            this._baseItem.setSize(60, 60);
            this._baseItem.move(15, 15);
            this._baseItem.isDragAble = false;
            addChild(this._baseItem);
            this._baseItem.setStrengthLabel(50, 45);
            this._icon = new Object /* flash.display.Bitmap */();
            this._icon.x = 2;
            this._icon.y = 2;
            addChild(this._icon);
            var loc1=new GTextFormat("", 12, 65535, null, null, null, null, null, flash.text.TextFormatAlign.CENTER);
            this._nameTxt = ObjCreate.createTextField("", 2, 80, 88, 20, this, loc1);
            this._nameTxt.mouseEnabled = false;
            this._changeTip = ObjCreate.createTextField("", 2, 55, 88, 20, this, loc1);
            this._changeTip.mouseEnabled = false;
            return;
        }

        /* internal  */onResLoaded(): void
        {
            this._icon.bitmapData = null;
            if (this._wardrobeItemInfo.state != WardrobeState.HadOverdue) 
            {
                if (this._wardrobeItemInfo.state != WardrobeState.HadEquip) 
                {
                    if (this._wardrobeItemInfo.state != WardrobeState.HadActive) 
                    {
                        if (this._wardrobeItemInfo.state == WardrobeState.HadMix) 
                        {
                            this._icon.bitmapData = GlobalClass.getBitmapData(ImagesConst.LabelHadMix);
                        }
                    }
                    else 
                    {
                        this._icon.bitmapData = GlobalClass.getBitmapData(ImagesConst.LabelActive);
                    }
                }
                else 
                {
                    this._icon.bitmapData = GlobalClass.getBitmapData(ImagesConst.LabelHadEquip);
                }
            }
            else 
            {
                this._icon.bitmapData = GlobalClass.getBitmapData(ImagesConst.LabelOverdue);
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            var loc5=null;
            var loc6=0;
            var loc7=0;
            this._wardrobeItemInfo = arg1.wardrobeItemInfo as WardrobeItemInfo;
            var loc2=arg1.type;
            if (this._wardrobeItemInfo && this._wardrobeItemInfo.itemData) 
            {
                loc1 = this._wardrobeItemInfo.itemData;
            }
            else if (this._wardrobeItemInfo) 
            {
                loc1 = new ItemData(this._wardrobeItemInfo.code);
            }
            this._baseItem.itemData = loc1;
            var loc3=ColorConfig.instance.getItemColor(loc1.color).color;
            this._nameTxt.htmlText = HTMLUtil.addColor(loc1.name, loc3);
            this._baseItem.filters = [];
            if (this._wardrobeItemInfo && this._wardrobeItemInfo.state == WardrobeState.NoActive) 
            {
                this._baseItem.filters = [FilterConst.colorFilter];
            }
            var loc4=Cache.instance.pack.rolePackCache.getAllItems();
            if (loc2 != WardrobeType.WardrobeWing) 
            {
                if (loc2 != WardrobeType.WardrobeFashion) 
                {
                    if (loc2 != WardrobeType.WardrobeFashionWeapon) 
                    {
                        if (loc2 != WardrobeType.WardrobeFootPrint) 
                        {
                            if (loc2 != WardrobeType.WardrobeBubble) 
                            {
                                if (loc2 != WardrobeType.WardrobeSurroung) 
                                {
                                    if (loc2 != WardrobeType.WardrobeWaistBelt) 
                                    {
                                        if (loc2 == WardrobeType.WardrobeElf) 
                                        {
                                            if (loc5 = loc4[(EDressPos._EDressPosElf - 1)]) 
                                            {
                                                loc6 = loc5.itemExInfo.ELFModel;
                                                loc7 = loc5.itemExInfo.bELFModel;
                                            }
                                        }
                                    }
                                    else if (loc5 = loc4[(EDressPos._EDressPosWaistBelt - 1)]) 
                                    {
                                        loc6 = loc5.itemExInfo.WBModel;
                                        loc7 = loc5.itemExInfo.bWBModel;
                                    }
                                }
                                else if (loc5 = loc4[(EDressPos._EDressPosSurround - 1)]) 
                                {
                                    loc6 = loc5.itemExInfo.SUModel;
                                    loc7 = loc5.itemExInfo.bSUModel;
                                }
                            }
                            else if (loc5 = loc4[(EDressPos._EDressPosBubble - 1)]) 
                            {
                                loc6 = loc5.itemExInfo.bubbleModel;
                                loc7 = loc5.itemExInfo.bbubbleModel;
                            }
                        }
                        else if (loc5 = loc4[(EDressPos._EDressPosFootPrint - 1)]) 
                        {
                            loc6 = loc5.itemExInfo.footprintModel;
                            loc7 = loc5.itemExInfo.bFootprintModel;
                        }
                    }
                    else if (loc5 = loc4[(EDressPos._EDressPosFashionWeapon - 1)]) 
                    {
                        loc6 = loc5.itemExInfo.weaponfashionModel;
                        loc7 = loc5.itemExInfo.bWeaponFashionModel;
                    }
                }
                else if (loc5 = loc4[(EDressPos._EDressPosFashion - 1)]) 
                {
                    loc6 = loc5.itemExInfo.fashionModel;
                    loc7 = loc5.itemExInfo.bFashionModel;
                }
            }
            else if (loc5 = loc4[(EDressPos._EDressPosWing - 1)]) 
            {
                loc6 = loc5.itemExInfo.windModel;
                loc7 = loc5.itemExInfo.bWindModel;
            }
            if (loc5 && this._wardrobeItemInfo && int(loc6) == this._wardrobeItemInfo.code && !(int(loc6) == int(loc7)) && this._wardrobeItemInfo.state == WardrobeState.HadMix) 
            {
                this._changeTip.htmlText = Language.getString(36132);
            }
            else 
            {
                this._changeTip.htmlText = "";
            }
            LoaderHelp.addResCallBack(ResFileConst.wardrobe, this.onResLoaded);
            return;
        }

        public onWardrobeItemClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._wardrobeItemInfo) 
            {
                this.dispatchEvent(new DataEvent(EventName.FashionBoxItemSelected, this._wardrobeItemInfo, false, true));
                if (KeyBoardManager.ctrlKey && this._wardrobeItemInfo.itemData) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ChatShowItem, this._wardrobeItemInfo.itemData));
                }
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (arg1) 
            {
                if (this._gradientGlow == null) 
                {
                    this._gradientGlow = new Object /* flash.filters.GradientGlowFilter */();
                    this._gradientGlow.distance = 0;
                    this._gradientGlow.angle = 45;
                    this._gradientGlow.colors = [16777062, 16776960];
                    this._gradientGlow.alphas = [0, 1];
                    this._gradientGlow.ratios = [0, 255];
                    this._gradientGlow.blurX = 5;
                    this._gradientGlow.blurY = 5;
                    this._gradientGlow.strength = 2;
                    this._gradientGlow.quality = flash.filters.BitmapFilterQuality.HIGH;
                    this._gradientGlow.type = flash.filters.BitmapFilterType.OUTER;
                }
                if (this._wardrobeItemInfo && this._gradientGlow) 
                {
                    this.filters = [this._gradientGlow];
                }
            }
            else 
            {
                this.filters = [];
            }
            return;
        }

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_icon: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_changeTip: Object /* flash.text.TextField */;

        /* internal */ /* var */_code: int;

        /* internal */ /* var */_wardrobeItemInfo: WardrobeItemInfo;

        /* internal */ /* var */_gradientGlow: Object /* flash.filters.GradientGlowFilter */;
    }
